from django import forms


class UserLForm(forms.Form):
    username = forms.CharField(
        # 提示信息
        label='用户名',
        #  最小长度约束
        min_length=4,
        # 最大长度约束
        max_length=10,
        # 错误信息提示
        error_messages={
            "min_length": "用户名长度大于4",
            "max_length": "用户名长度小于10",
        }
    )
    password = forms.CharField(
        label='密码',
        min_length=6,
        max_length=20,
        error_messages={
            "min_length": "密码长度大于6",
            "max_length": "密码长度小于20",
        },
        # input输入框的类型发生了改变 默认是text文本类型
        # 需要修改为密码框类型
        widget=forms.PasswordInput()
    )
    # 确认密码
    password2 = forms.CharField(
        label='确认密码',
        min_length=6,
        max_length=20,
        error_messages={
            "min_length": "密码长度大于6",
            "max_length": "密码长度小于20",
        },
        widget=forms.PasswordInput()
    )
    # 邮箱验证
    email = forms.EmailField(
        label='邮箱',
        error_messages={
            "invalid": "邮箱格式错误"
        }
    )
